<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/include/tagLib.jsp" %>
<c:set var="ctxStaticChat" value="${pageContext.request.contextPath}/assets/chat"/>

<!doctype html>
<html lang="en">
<head>
    <title>${sieName}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <%@include file="/include/cssLib.jsp" %>

    <link rel="stylesheet" type="text/css" href="${ctxStaticChat }/css/qq.css"/>
    <link rel="stylesheet" href="${ctxStatic }/introjs/introjs.css" />
</head>

<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <!-- 菜单 -->
            <tag:nav key="searchOptimize"/>

            <div class="tab-content">
                <div class="tab-pane active">
                    <div class="card col-md-10 col-md-offset-1">
                        <tag:search-nav key="qaList"/>
                        <div class="col-md-5">
                            <br><br><br><br>
                            <div class="qqBox">
                                <div class="BoxHead">
                                    <div class="headImg">
                                        <img src="${ctxStaticChat }/img/avatar/robot.jpg"/>
                                    </div>
                                    <div class="internetName">问答小助手</div>
                                </div>
                                <div class="context">
                                    <div class="conLeft" data-step="1" data-intro="选择您要优化的搜索分类">
                                        <ul>
                                            <c:forEach items="${fns:getBizJsonDataMap('qa_category_list')}" var="map" varStatus="vStatus">
                                                <li>
                                                    <div class="liLeft"><img src="${ctxStaticChat }/img/avatar/${vStatus.index+1}.jpg"/></div>
                                                    <div class="liRight">
                                                        <span  class="intername" data-id="${map.key}">${map.value}</span>
                                                        <span class="infor"></span>
                                                    </div>
                                                </li>
                                            </c:forEach>
                                        </ul>
                                    </div>
                                    <div class="conRight">
                                        <div class="Righthead">
                                            <div class="headName">分类：</div>
                                        </div>
                                        <div class="RightCont">
                                            <ul class="newsList">

                                            </ul>
                                        </div>
                                        <div class="RightFoot" data-step="2" data-intro="引导提示：输入您要咨询的问题">
                                            <div class="emjon">
                                                <ul>
                                                    <li><img src="${ctxStaticChat }/img/em/em_02.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_05.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_07.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_12.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_14.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_16.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_20.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_23.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_25.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_30.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_31.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_33.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_37.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_38.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_40.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_45.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_47.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_48.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_52.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_54.jpg"/></li>
                                                    <li><img src="${ctxStaticChat }/img/em/em_55.jpg"/></li>
                                                </ul>
                                            </div>
                                            <div class="footTop">
                                                <ul>
                                                    <li class="ExP"><img src="${ctxStaticChat }/img/20170926103645_33.jpg"/></li>
                                                    <li class="text-gray">&nbsp;&nbsp;启用搜索引擎：
                                                        <c:forEach items="${fns:getSpiderTaskList()}" var="task" varStatus="vStatus">
                                                            &nbsp;<input type="checkbox" name="spiderId" ${vStatus.index==0?'checked':''} value="${task.id}" title="${task.title}"/>${task.title}
                                                        </c:forEach>
                                                    </li>
                                                </ul>
                                            </div>
                                            <div class="inputBox">
                                                <textarea id="dope" class="inputBox" name="" placeholder="输入..."></textarea>
                                                <button class="sendBtn">查询(s)</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="col-md-7">
                            <div class="card-content hide">
                                <div class="row">
                                    <div class="col-sm-12">
                                        <form id="searchForm" action="${ctx}/adminConsole/searchOptimize/pageList?module=qa" method="post">
                                            <div class="col-md-3 col-md-offset-4">
                                                <input id="keyword" name="keyword" type="text" value="${keyword}">
                                                <input type="hidden" id="pageNo" name="pageNo"/>
                                                <input type="hidden" id="pageSize" name="pageSize" />
                                                <input type="hidden" id="orderBy" name="page.orderBy" value="${orderBean.orderBy}"/>
                                                <input type="hidden" id="order" name="page.order" value="${orderBean.order}"/>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <ul id="qaTabList" class="nav nav-pills nav-pills-info nav-pills-icons" role="tablist">
                                <li class="active">
                                    <a href="#tasks-sys" id="tab-a-${tasks-sys}" role="tab" data-toggle="tab">系统问答库</a>
                                </li>
                                <c:forEach items="${fns:getSpiderTaskList()}" var="task">
                                    <li>
                                        <a href="#tasks-${task.id}" id="tab-a-${task.id}" role="tab" data-toggle="tab">${task.title}</a>
                                    </li>
                                </c:forEach>
                            </ul>

                            <div class="tab-content">
                                <div class="tab-pane active" id="tasks-sys">
                                    <div class="table-responsive" data-step="3" data-intro="引导提示：选择您要采纳答案，搜索引擎采纳的答案 将会自动划分到当前分类下">
                                        <table id="datatables" class="table table-bordered table-hover" cellspacing="0" width="100%" style="width:100%">
                                            <thead>
                                            <tr>
                                                <th width="55" class="text-warning">操作</th>
                                                <th width="50" class="text-warning">分数</th>
                                                <th width="250">问题</th>
                                                <th>内容</th>
                                                <th width="100">分类</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <c:forEach items="${fns:getSpiderTaskList()}" var="task">
                                    <div class="tab-pane" id="tasks-${task.id}">
                                        <div class="card-content bd-grey"></div>
                                    </div>
                                </c:forEach>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@include file="/include/sidebarRight.jsp" %>
</body>
<%@include file="/include/scriptLib.jsp" %>
<script src="${ctxStatic }/introjs/intro.js"></script>
<script type="text/javascript" src="${ctxStatic }/jquery-plugs/jquery.datatables.js"></script>
<script src="${ctxStaticChat }/js/chat.js"></script>
<script type="text/javascript" src="${ctxStatic }/js/biz/qaList.js"></script>

<style type="text/css">
    #datatables_filter{display: none;}
    #datatables_length{display: none;}
    #datatables_paginate{text-align: left;}
    table.dataTable span.highlight {
        background-color: #FFFF88;
    }
</style>
<script type="text/javascript">

    function searchAnswer(keyword){
        __table.search(keyword).draw();

        $("input[name=spiderId]").each(function(){
            var spiderId = $(this).val();
            if($(this).is(":checked")){
                HttpUtil.ajaxAsyncJsonPostSimple('/adminConsole/searchOptimize/getSpiderData', {spiderTaskId:spiderId, keyword:keyword}, function(data){
                    if(CommUtil.isNotEmpty(data)){
                        var item = null;
                        var htm = new StringBuffer();
                        for(var i=0; i<data.length; i++){
                            if(i > 0){
                                htm.append("<hr class='mg-0'/>");
                            }
                            item = data[i];
                            htm.append("<strong>"+item.question+"<a class='font-13 mgl-20 text-warning' href=\"javascript:caina("+i+", '"+spiderId+"')\"><i class='fa fa-heart'></i>采纳</a></strong>");
                            htm.append("<p>"+item.answer+"</p>");
                        }
                        $("#tasks-"+spiderId+" .card-content").html(htm.toString());
                    }else{
                        $("#tasks-"+spiderId+" .card-content").html('');
                    }
                });
            }else{
                $("#tasks-"+spiderId+" .card-content").html('');
            }
        });
    }

    function caina(index, taskId){
        var categoryId = $(".conLeft li.bg").children('.liRight').children('.intername').data("id");
        var answerText = null;
        if("tasks-sys" == taskId){
            answerText = $("#datatables tbody tr:eq("+index+")").children("td:eq(3)").text();
        }else{
            answerText = $("#tasks-"+taskId+" .card-content").find("p:eq("+index+")").text();
        }

        if(CommUtil.isNotEmpty(answerText)){
            answers(answerText);
        }

        if(CommUtil.isNotEmpty(taskId) && "tasks-sys" != taskId){
            HttpUtil.ajaxAsyncJsonPost('/adminConsole/searchOptimize/adoptQASpiderData', {firstCategoryId:categoryId, index:index, taskId: taskId}, function(message){
                dialogRightTopTip(message);
            });
        }
    }
</script>

</html>